#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
账本 - 商户分账绑定查询功能使用示例
"""

from examples.base_example import BaseExample
from jlpay.services.ledger.merchconf_service import MerchconfService
from jlpay.model.ledger.merchconf import MerchRevBindQueryRequest


class MerchRevBindQueryExample(BaseExample):
    """商户分账绑定查询示例类"""
    
    def __init__(self):
        """初始化示例类"""
        super().__init__("examples.ledger.merchconf.bind_query")
        self.service = MerchconfService(self.config)
    
    def build_merch_rev_bind_query_request(self):
        """构建商户分账绑定查询请求"""
        request = MerchRevBindQueryRequest()
        
        # 设置请求参数
        request.set_org_code("50720711")
        request.set_mch_id("849581183510017")
        request.set_rev_mch_id("849602058120001")  # 可选参数
        
        return request
    
    def demo(self):
        """执行商户分账绑定查询示例"""
        self.logger.info("开始执行商户分账绑定查询示例")
        
        # 创建商户分账绑定查询请求
        request = self.build_merch_rev_bind_query_request()
        
        # 发送请求
        response = self.send_request_and_handle_response(
            self.service.query_merch_rev_bind,
            "商户分账绑定查询",
            request
        )
        
        # 处理响应结果
        if response and response.is_success():
            self.logger.info(f"响应报文：{response.to_dict()}")


if __name__ == "__main__":
    example = MerchRevBindQueryExample()
    example.logger.info("=" * 50)
    example.logger.info("===== 商户分账绑定查询示例 开始 =====")
    example.logger.info("=" * 50)
    
    example.demo()
    
    example.logger.info("=" * 50)
    example.logger.info("===== 商户分账绑定查询示例执行完毕 =====")
    example.logger.info("=" * 50) 